/**
 * 
 */
package com.mitrais.training.yoga;

/**
 * @author Yoga_K
 *
 */
public class WimCycle implements IBike {
	private int gear;
	private double speed;
	private int maxSpeed;
	
	public WimCycle(){
		gear = 0;
		speed = 0;
		maxSpeed = 100;
	}
	
	/**
	 * @return the gear
	 */
	public int getGear() {
		return gear;
	}

	/**
	 * @return the speed
	 */
	public double getSpeed() {
		return speed;
	}

	/**
	 * @return the maxSpeed
	 */
	public int getMaxSpeed() {
		return maxSpeed;
	}
	
	/* (non-Javadoc)
	 * @see com.mitrais.training.yoga.IBike#changeGear(int)
	 */
	@Override
	public void changeGear(int gear) {
		// TODO Auto-generated method stub
		if(gear < 0 || gear == 0){
			System.out.println("Invalid gear");
		}else{
			this.gear = this.gear + gear;
		}		
		return;
	}

	/* (non-Javadoc)
	 * @see com.mitrais.training.yoga.IBike#speedUp(int)
	 */
	@Override
	public void speedUp(int speed) {
		// TODO Auto-generated method stub
		if(speed + this.speed > maxSpeed){
			System.out.println("Speed can not exceed 100");
			this.speed = maxSpeed;
		}else{
			this.speed = this.speed + speed;
		}
		return;
	}

	/* (non-Javadoc)
	 * @see com.mitrais.training.yoga.IBike#applyBrake(int)
	 */
	@Override
	public void applyBrake(int brake) {
		// TODO Auto-generated method stub
		double percentage = (double) (brake*5)/100;
		//System.out.println(""+percentage);
		this.speed = this.speed - (percentage*this.speed);
		return;
	}
	
}
